import BaseUtil from "@/BaseUtil";
import {d_进攻怪} from "../../xlsx/单位/进攻怪";
import ActorUnitUtil from "@/ActorUnitUtil";
import {l_左进攻怪路径} from "../../_sl_editor/l_左进攻怪路径";
import {l_右进攻怪路径} from "../../_sl_editor/l_右进攻怪路径";
import RectUtil from "@/RectUtil";
import UnitStateUtil from "@/UnitStateUtil";
import TimerDialogUtil from "@/TimerDialogUtil";

export default class 刷兵系统 {


    constructor() {
        TimerDialogUtil.show("下一波",10)
        BaseUtil.onTimer(10,(count)=>{
            let element = d_进攻怪[count];

            ActorUnitUtil.createActorUnit(Player(11),element.id,l_左进攻怪路径[0].x,l_左进攻怪路径[0].y,0,10)
            ActorUnitUtil.createActorUnit(Player(11),element.id,l_右进攻怪路径[0].x,l_右进攻怪路径[0].y,0,10)


            TimerDialogUtil.show("下一波Lv."+count,10)

            return true;
        });
        刷兵系统.命令向下个路径走(l_左进攻怪路径)
        刷兵系统.命令向下个路径走(l_右进攻怪路径)

    }


    static 命令向下个路径走(line:Vector[]){

        for (let i = 0; i < line.length-1; i++) {
            let vector = line[i];
            let vector2 = line[i+1];
            let rect = RectUtil.createRect(vector.x,vector.y,1000,1000);
            se.onEnterRect(rect,e => {
                if (e.trigUnitOwnerId>9){
                    UnitStateUtil.orderAttack(e.trigUnit,vector2.x,vector2.y)
                }


            })




        }


    }
}